#include "Lua_UI.h"
#include "QtPlugIn/qtguilib.h"
#include "LogLib/GlobalLogger.h"
SCRIPTED_CFUNC_DECLARE_SRC(LuaLoadDialog)
{
	lua_getglobal(L,"LoadDialog");
	if (!lua_isfunction(L,-1))
		LOG_INFO("[LoadDialog] is not a function.");
	else
	{
		if (lua_pcall(L, 0, 0, 0))
			LOG_INFO("call func: \'LoadDialog\' error.");
	}
	const char * name = GetFileNameByLoadDialog();
	if(name != 0)
	{
		lua_pushfstring(L,name);
		return 1;
	}
	return 0;
}

//////////////////////////////////////////////////////////////////////////
static const struct luaL_reg UISys [] = {
	{"LoadDialog", LuaLoadDialog},
	{NULL, NULL} /* sentinel */
};

int luaopen_UISys (lua_State *L)
{
	luaL_openlib(L, "UISys", UISys, 0);
	return 1;
}